<template>
  <div class="side-tabs">
    <div
      v-for="tab in tabs"
      :key="tab.anchor"
      :class="['side-tab-item', { active: tab.anchor === props.activeTab }]"
      @click="onTabClick(tab.anchor)"
    >
      <img src="/clock.svg" class="tab-icon" alt="tab-icon" />
      <span class="tab-label">{{ tab.label }}</span>
    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  tabs: Array, // [{ label, anchor }]
  activeTab: String,
});
const emit = defineEmits(["jump"]);
function onTabClick(anchor) {
  emit("jump", anchor);
}
</script>

<style scoped>
.side-tabs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
  border-radius: 16px;
  padding: 18px 0;
  width: 180px;
  min-width: 180px;
  align-items: stretch;
  box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.03);
  margin: 0 auto;
  height: 85%;
}
.side-tab-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  color: #444;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-weight: 400;
  background: transparent;
  margin: 10px;
}
.side-tab-item.active {
  background: #f5f8ff;
  color: #1f69ff;
  background-color: #eef2fb;
  font-weight: 600;
  position: relative;
}
.side-tab-item.active .tab-icon {
  color: #1f69ff;
  background-color: #eef2fb;
  margin-right: 4px;
  display: inline-block;
}
.side-tab-item .tab-icon {
  font-size: 16px;
  color: #b0b6c3;
  display: flex;
  align-items: center;
  margin-right: 4px;
}
.side-tab-item:hover:not(.active) {
  background: #f7f8fa;
}
.tab-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  justify-content: center;
  display: flex;
}
</style>
